package com.xjy.web.controller.controller;

import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.enums.BusinessType;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.system.domain.bo.ReportExpendBudgetDetailQueryBo;
import com.xjy.system.domain.vo.ReportExpendBudgetDetailVo;
import com.xjy.system.service.IReportExpendBudgetDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 报销科目明细Controller
 *
 * @author mlb
 * @date 2022-03-22
 */
@Api(value = "报销科目明细控制器", tags = {"报销科目明细管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/report_expend_budget_detail")
public class ReportExpendBudgetDetailController extends BaseController {

    private final IReportExpendBudgetDetailService iReportExpendBudgetDetailService;

    /**
     * 查询报销科目明细列表
     */
    @ApiOperation("查询报销科目明细列表")
//    @PreAuthorize("@ss.hasPermi('system:report_expend_budget_detail:list')")
    @GetMapping("/list")
    public TableDataInfo<ReportExpendBudgetDetailVo> list(@Validated ReportExpendBudgetDetailQueryBo bo) {
        return iReportExpendBudgetDetailService.queryPageList(bo);
    }

    /**
     * 导出报销科目明细列表
     */
    @ApiOperation("导出报销科目明细列表")
    @PreAuthorize("@ss.hasPermi('system:report_expend_budget_detail:export')")
    @Log(title = "报销科目明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ReportExpendBudgetDetailVo> export(@Validated ReportExpendBudgetDetailQueryBo bo) {
        List<ReportExpendBudgetDetailVo> list = iReportExpendBudgetDetailService.queryList(bo);
        ExcelUtil<ReportExpendBudgetDetailVo> util = new ExcelUtil<ReportExpendBudgetDetailVo>(ReportExpendBudgetDetailVo.class);
        return util.exportExcel(list, "报销科目明细");
    }

    /**
     * 获取报销科目明细详细信息
     */
    @ApiOperation("获取报销科目明细详细信息")
    @PreAuthorize("@ss.hasPermi('system:report_expend_budget_detail:query')")
    @GetMapping("/{projId}")
    public AjaxResult<ReportExpendBudgetDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("projId") Long projId) {
        return AjaxResult.success(iReportExpendBudgetDetailService.queryById(projId));
    }
}
